package crontab

import (
	"longmen/server/internal/services/nami/services/sports/basketball/bbcache"
	"longmen/server/internal/services/nami/services/sports/football/fbcache"
	"time"
)

var b *bbcache.LineUpCache
var f *fbcache.LineUpCache

func MatchSync() {
	timeTick := time.NewTicker(100 * time.Second)
	for {
		select {
		case <-timeTick.C:
			basketBallLineupSync()
			footBallLineupSync()
		}
	}
}

// basketBallLineup 篮球阵容同步
func basketBallLineupSync() {
	if b == nil {
		b = bbcache.NewLineUpCache()
	}
	rs := b.GetAllLineUp()
	for _, k := range rs {
		b.WriteToEs(k)
	}

}

// basketBallLineup 足球阵容同步
func footBallLineupSync() {
	if f == nil {
		f = fbcache.NewLineUpRedis()
	}
	fs := f.GetAllLineUp()
	for _, k := range fs {
		f.WriteToEs(k)
	}
}
